part of "../popup.dart";

/// 一张带圆角的卡片
class CardDialog extends StatelessWidget {
  final Widget child;
  const CardDialog({required this.child, super.key});

  @override
  Widget build(BuildContext context) {
    return Dialog(
      // 卡片周围有圆角
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(6),
      ),
      // Dialog的颜色为黑色
      surfaceTintColor: COLOR.blackPure,
      backgroundColor: COLOR.blackPure,
      child: LayoutBuilder(
        builder: (_, constraint) {
          // 卡片有最低限度的宽高和边距
          return ConstrainedBox(
            constraints: BoxConstraints(
              minWidth: constraint.maxWidth * 0.5,
            ),
            child: Padding(
              padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 40),
              child: child,
            ),
          );
        },
      ),
    );
  }
}
